<?php
// echo '<pre>';
// print_r($_SERVER);exit;

require_once $_SERVER['DOCUMENT_ROOT'].'/blog/lib/Db.php'; //绝对地址

$db=new Db();
// $res=$db->table('cates')->where(array('id'=>1,'title'=>'abcd'))->item();
// $res=$db->table('cates')->field('id,title')->order('id desc')->where('id>0')->limit(2)->lists();
// $data=array('title'=>'电风扇');
// $id=$db->table('cates')->insert($data);

// $rst=$db->table('cates')->where(array('id'=>3))->delete();
// var_dump($rst);

// $data=['title'=>'数据库更新'];
// $res=$db->table('cates')->where(array('id'=>2))->update($data);
// var_dump($res);

$page=$_GET['page'];
$pageSize=1;
$res=$db->table('article')->field('id,title')->where('id>0')->pages($page,$pageSize,'/blog/test.php');
// echo json_encode($res); //返回json数据
// echo '共查询出'.$res['total'].'条数据<br>';
// foreach ($res['data'] as $key => $value) {
// 	echo $value['title'].'<br>';
// }


// $db->table('cates')->field('id')->where('id>0')->count();

// echo '<pre>';
// print_r($res);
// var_dump($id);



?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>分页</title>
	<link rel="stylesheet" href="static/plugins/bootstrap/bootstrap.min.css">
	<!-- <script src="static/plugins/jquery.min.js"></script>
    <script src="static/plugins/bootstrap/bootstrap.min.js"></script> -->
</head>
<body>
	<div class="container">
		<p>总数据<?php echo $res['total']?>条</p>
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>ID</th>
					<th>标题</th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($res['data'] as $cates){?>
				<tr>
					<td><?php echo $cates['id']?></td>
					<td><?php echo $cates['title']?></td>
				</tr>
				<?php }?>
			</tbody>
		</table>

		<!-- 分页 -->
		<div>
			<?php echo $res['pages']?>
		</div>
	</div>
</body>
</html>